package cn.yj.register.configType;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author Liyj
 */
public interface RegisterConfigTypeCondition extends Condition {

	@Override
	default boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
		Environment environment = conditionContext.getEnvironment();
		String defaultType = "LOCAL";
		String property = environment.getProperty("spring.rpc.config-type", defaultType);
		return matches(property);
	}

	boolean matches(String configType);
}
